﻿using System;
namespace Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000 {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="atm2", Namespace="http://producers.ehma-10000000.xtee.riik.ee/producer/ehma-10000000", Target=typeof(Atm2))]
    public class Atm2Serializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IAtm2 clazz;
        
        public Atm2Serializer(IAtm2 clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("gameid");
            if (clazz.Gameid!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Gameid))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Gameid");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("gamename");
            if (clazz.Gamename!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Gamename))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Gamename");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("gameversofno");
            if (clazz.Gameversofno!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Gameversofno))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Gameversofno");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("gamepurchd");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Gamepurchd))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("gamemnf");
            if (clazz.Gamemnf!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Gamemnf))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Gamemnf");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("certcompno");
            if (clazz.Certcompno!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Certcompno))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Certcompno");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("certcompd");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Certcompd))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("nameindpex");
            if (clazz.Nameindpex!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Nameindpex))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Nameindpex");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("assindpex");
            if (clazz.Assindpex!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Assindpex))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Assindpex");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("evidgameown");
            if (clazz.Evidgameown!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Evidgameown))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Evidgameown");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("usestarttime");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "dateTime");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDateTime(((System.DateTime)(clazz.Usestarttime))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("useendtime");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "dateTime");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDateTime(((System.DateTime)(clazz.Useendtime))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="gameid") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm2>gameid");
                }
                clazz.Gameid = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("gameid")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm2>gameid", Reader.LocalName);
            }
            if (Reader.LocalName=="gamename") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm2>gamename");
                }
                clazz.Gamename = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("gamename")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm2>gamename", Reader.LocalName);
            }
            if (Reader.LocalName=="gameversofno") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm2>gameversofno");
                }
                clazz.Gameversofno = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("gameversofno")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm2>gameversofno", Reader.LocalName);
            }
            if (Reader.LocalName=="gamepurchd") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm2>gamepurchd");
                }
                clazz.Gamepurchd = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("gamepurchd")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm2>gamepurchd", Reader.LocalName);
            }
            if (Reader.LocalName=="gamemnf") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm2>gamemnf");
                }
                clazz.Gamemnf = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("gamemnf")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm2>gamemnf", Reader.LocalName);
            }
            if (Reader.LocalName=="certcompno") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm2>certcompno");
                }
                clazz.Certcompno = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("certcompno")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm2>certcompno", Reader.LocalName);
            }
            if (Reader.LocalName=="certcompd") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm2>certcompd");
                }
                clazz.Certcompd = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("certcompd")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm2>certcompd", Reader.LocalName);
            }
            if (Reader.LocalName=="nameindpex") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm2>nameindpex");
                }
                clazz.Nameindpex = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("nameindpex")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm2>nameindpex", Reader.LocalName);
            }
            if (Reader.LocalName=="assindpex") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm2>assindpex");
                }
                clazz.Assindpex = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("assindpex")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm2>assindpex", Reader.LocalName);
            }
            if (Reader.LocalName=="evidgameown") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm2>evidgameown");
                }
                clazz.Evidgameown = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("evidgameown")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm2>evidgameown", Reader.LocalName);
            }
            if (Reader.LocalName=="usestarttime") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm2>usestarttime");
                }
                clazz.Usestarttime = new global::Xtee.Core.Schema.XsdDateTime(Reader.ReadElementString("usestarttime")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm2>usestarttime", Reader.LocalName);
            }
            if (Reader.LocalName=="useendtime") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm2>useendtime");
                }
                clazz.Useendtime = new global::Xtee.Core.Schema.XsdDateTime(Reader.ReadElementString("useendtime")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm2>useendtime", Reader.LocalName);
            }
        }
    }
}
